import {  L_request } from './request.js'

/**
 * 获得轮播图数据
 */
export function getBanner() {
	return L_request({
		url: 'index/index/getbanner',
	})
}
/**
 * 获得热门推荐数据
 */
export function getHotRecommend() {
	return L_request({
		url: 'index/index/getHotRecommend',
	})
}
/**
 * 最新商品
 */

export function getNewGoods() {
	return L_request({
		url: 'index/index/getNewGoods',
	})
}

/**
 * 分类商品
 */

export function getCategory() {
	return L_request({
		url: 'index/index/getCategory',
	})
}

/**
 * 用户注册
 */

export function register(data)
{
  return L_request({
    url: 'index/index/register',
    method:'post',
    data,
    headers: {
			'Content-Type': 'application/x-www-from-urlencoded',
		},
	})
}
/**
 * 用户登录
 */


export function userLogin(data)
{
  return L_request({
    url: 'index/index/userLogin',
    method:'post',
    data,
    headers: {
			'Content-Type': 'application/x-www-from-urlencoded',
		},
	})
}

/**
 * 获得用户信息
 */

export function getLoginUser(data)
{
  return L_request({
    url: 'index/index/getLoginUser',
    headers: {
      'Access-Token': window.localStorage.getItem('front_token') || '',
		},
	})
}

/**
 * 用户退出登录
 */
export function userLogout(token)
{
  return L_request({
    url: 'index/index/userLogout',
    headers: {
      'Access-Token': token,
		},
	},false)
}

/**
 * 用户上传头像
 */

export function headUpload(data)
{
  return L_request({
    url: 'index/index/headUpload',
    data,
    method:'post',
    headers: {
      'Content-Type': 'multipart/form-data',
      'Access-Token':window.localStorage.getItem('front_token') || ''
      
		},
	},false)
}



/**
 * 聊天上传图片
 * @param {*} data 
 */
export function chatImgLoad(data)
{
  return L_request({
    url: 'index/index/chatImgLoad',
    data,
    method:'post',
    headers: {
      'Content-Type': 'multipart/form-data',
		},
	},false)
}




// 修改用户信息
export function editUserInfo(data)
{
  return L_request({
    url: 'index/index/editUserInfo',
    data,
    method:'post',
    headers: {
      'Content-Type': 'application/x-www-from-urlencoded',
      'Access-Token':window.localStorage.getItem('front_token') || ''
		},
	},false)
}
export function userTopUp(data)
{
  return L_request({
    url: 'index/user/userTopUp',
    data,
    method:'post',
    headers: {
      'Content-Type': 'application/x-www-from-urlencoded',
      'Access-Token':window.localStorage.getItem('front_token') || ''
		},
	})
}
export function getOrders()
{
  return L_request({
    url: 'index/user/getOrders',
    headers: {
      'Access-Token':window.localStorage.getItem('front_token') || ''
		},
	})

}

export function getMyGoods()
{
  return L_request({
    url: 'index/user/getMyGoods',
    headers: {
      'Access-Token':window.localStorage.getItem('front_token') || ''
		},
	})

}

export function getCollectGoods()
{
  return L_request({
    url: 'index/user/getCollectGoods',
    headers: {
      'Access-Token':window.localStorage.getItem('front_token') || ''
		},
	})

}

export function getUserChatLog(){
  return L_request({
    url: 'index/user/getUserChatLog',
    headers: {
      'Access-Token':window.localStorage.getItem('front_token') || ''
		}
	},false)

}

// 增加用户浏览记录

export function addHistory(data){
  return L_request({
    url: 'index/user/addHistory',
    data,
    method:'post',
    headers: {
      'Access-Token':window.localStorage.getItem('front_token') || ''
		}
	},false)

}
// 用户获得历史记录
export function getHistory(){
  return L_request({
    url: 'index/user/getHistory',
    headers: {
      'Access-Token':window.localStorage.getItem('front_token') || ''
		},
	})
}



